package p3.entity;

public class ParkingArea {
    private ParkingLot[] lots=new ParkingLot[100];
    private Admin[] admins=new Admin[3];
    public ParkingLot[] getLots() {
        return lots;
    }

    public Admin[] getAdmins() {
        return admins;
    }

    public void init(){
        for (int i=0;i<= lots.length-1;i++){
            lots[i]=new ParkingLot();
            lots[i].setLotNo("No."+(i+1));
        }
    }
    public Car findCarByCarNo(String carNo){
        for (int i=0;i<=lots.length-1;i++){
            Car car=lots[i].getCar();
            if (car!=null){
                if (car.getCarNo().equals(carNo)){
                    return car;
                }
            }
        }
        return null;
    }

    public int getFreeLots(){
        int count=0;
        for (int i=0;i<=lots.length-1;i++){
            if (lots[i].getCar()==null){
                count++;
            }
        }
        return count;
    }
}
